import java.util.LinkedList;
import java.util.List;
import java.util.Queue;

class Solution1 {
    static class TreeNode {
        char val;
        Demo.TreeNode left;
        Demo.TreeNode right;
        TreeNode(char val){
            this.val = val;
        }
    }

    public List<List<Integer>> levelOrderBottom(TreeNode root) {

        List<List<Integer>> list = new LinkedList<>();

        Queue<TreeNode> queue = new LinkedList<>();

        if(root == null){

            return list;

        }

        queue.offer(root);

        while(!queue.isEmpty()){

            int size = queue.size();

            List<Integer> ret = new LinkedList<>();

            while(size!=0){

                TreeNode cur = queue.poll();

                size--;

                //ret.add(cur.val);

                //if(cur.left!=null)

                    //queue.offer(cur.left);

                //if(cur.right!=null)

                    //queue.offer(cur.right);

            }

            list.add(0,ret);

        }

        return list;

    }

}